import 'babel-polyfill' //放置顶部
import Es6Promise from 'es6-promise'//放置顶部
import ResizeObserver from 'resize-observer-polyfill';
import Vue from "vue";
import dayjs from 'dayjs';
import axios from "axios"
import store from "@/store";
import lodash from "lodash";
import * as utils from '@/utils'; // 汇总组件导出
import VFormRender from "@c/public/form-render/index.vue";
import {loadExtension} from "@/extension/extension-loader";
import CompsLayers from '@/components/public/layer/scenes/index';
import Directives from '@/directives'; // 全局自动指令
import Vant from 'vant';
import x2js from 'x2js'
import 'vant/lib/index.css';
import "swiper/dist/css/swiper.min.css";
import "@/components/assets/iconfont/iconfont.css";

// 自定义富文本的样式
import "@/components/assets/style/quillEditor.scss";

import Editor from "@/components/public/layer/template/formEditor2";

Es6Promise.polyfill();

// 增加判断如果不支持当前依赖再设置即可
if (!(window.ResizeObserver)) {
    window.ResizeObserver = ResizeObserver;
}

Vue.use(Vant);

// 挂载全局定义副文本组件
Vue.component('Editor', Editor);

loadExtension();
const components = [
    VFormRender
];
// 注册
for (let key in CompsLayers) {
    components.push(CompsLayers[key])
}

for (let key in Directives) {
    Vue.directive(key, Directives[key])
}

const install = (Vue) => {
    window.axios = axios
    components.forEach(component => {
        Vue.component(component.name, component)
    })
    Vue.prototype.$store = store;
    Vue.prototype.$day = dayjs;
    Vue.prototype.$lodash = lodash;
    Vue.prototype.$utils = utils.default.utils;
    Vue.prototype.$x2js = new x2js();
}

if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue);
}

export default {
    install,
    VFormRender,
    ...CompsLayers
}
